﻿<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Script file="TweetCraftFrame.lua" />

  <Button name="TweetCraftTabButtonTemplate" virtual="true">
    <ButtonText name="$parentNormalText" nonspacewrap="true">
      <Anchors>
        <Anchor point="LEFT">
          <Offset>
            <AbsDimension x="8" y="0"/>
          </Offset>
        </Anchor>
      </Anchors>
    </ButtonText>
    <NormalFont style="GameFontNormalLeft"/>
    <HighlightFont style="GameFontHighlightLeft"/>
    <DisabledFont style="GameFontHighlightLeft"/>
  </Button>

  <Button name="TweetCraftTweetButtonTemplate" virtual="true">
    <Size>
      <AbsDimension x="294" y="52"/>
    </Size>
    <Layers>
      <Layer level="ARTWORK">
        <Texture name="$parentPicture">
          <Size x="48" y="48" />
          <Anchors>
            <Anchor point="LEFT">
              <Offset>
                <AbsDimension x="2" y="0" />
              </Offset>
            </Anchor>
          </Anchors>
          <TexCoords left="0.125" top="0.125" bottom="0.875" right="0.875"/>
        </Texture>
      </Layer>
      <Layer level="OVERLAY">
        <FontString name="$parentScreenName" text="Twitter User" justifyH="LEFT" justifyV="TOP"  inherits="GameFontNormal">
          <Size>
            <AbsDimension x="100" y="16" />
          </Size>
          <Anchors>
            <Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeTo="$parentPicture">
              <Offset x="5" y="2" />
            </Anchor>
          </Anchors>
        </FontString>
        <FontString name="$parentDateSent" text="1h ago" justifyH="RIGHT" justifyV="TOP" inherits="GameFontNormalSmall">
          <Size>
            <AbsDimension x="100" y="16" />
          </Size>
          <Anchors>
            <Anchor point="TOPRIGHT" relativePoint="TOPRIGHT" relativeTo="$parentPicture">
              <Offset x="240" y="2" />
            </Anchor>
          </Anchors>
        </FontString>

        <FontString name="$parentMessage" text="Status Message" justifyH="LEFT" justifyV="TOP" inherits="GameFontHighlightSmall">
          <Size>
            <AbsDimension x="235" y="32" />
          </Size>
          <Anchors>
            <Anchor point="TOPLEFT" relativePoint="BOTTOMLEFT" relativeTo="$parentScreenName" />
          </Anchors>
        </FontString>
      </Layer>
    </Layers>
    
    <Frames>
      <Button name="$parentDeleteButton" hidden="true">
        <Size>
          <AbsDimension x="32" y="32"/>
        </Size>
        <Anchors>
          <Anchor point="TOPRIGHT">
            <Offset>
              <AbsDimension x="5" y="7"/>
            </Offset>
          </Anchor>
        </Anchors>
        <HitRectInsets>
          <AbsInset left="9" right="7" top="-7" bottom="10"/>
        </HitRectInsets>
        <Scripts>
          <OnClick>
            TweetButton_OnDelete(self:GetParent().tweet)
          </OnClick>
          <OnEnter>
            self:Show()
            TweetCraft.AddNewbieTip(self, "Delete", 1, 1, 1, "Deletes the tweet from the outgoing queue.", 1)
          </OnEnter>
          <OnLeave>
            self:Hide()
            GameTooltip:Hide()
          </OnLeave>
        </Scripts>
        <NormalTexture file="Interface\Buttons\CancelButton-Up"/>
        <PushedTexture file="Interface\Buttons\CancelButton-Down"/>
        <HighlightTexture file="Interface\Buttons\CancelButton-Highlight" alphaMode="ADD"/>
      </Button>

      <Button name="$parentRetweetButton" hidden="true">
        <Size>
          <AbsDimension x="35" y="35"/>
        </Size>
        <Anchors>
          <Anchor point="TOPRIGHT">
            <Offset>
              <AbsDimension x="0" y="-14"/>
            </Offset>
          </Anchor>
        </Anchors>
        <Scripts>
          <OnClick>
            TweetButton_OnRetweet(self:GetParent().tweet)
          </OnClick>
          <OnEnter>
            self:Show()
            TweetCraft.AddNewbieTip(self, "Retweet", 1, 1, 1, "Prepares the tweet for retweeting.", 1)
          </OnEnter>
          <OnLeave>
            self:Hide()
            GameTooltip:Hide()
          </OnLeave>
        </Scripts>
        <NormalTexture file="Interface\Buttons\UI-RotationRight-Button-Up"/>
        <PushedTexture file="Interface\Buttons\UI-RotationRight-Button-Down"/>
        <HighlightTexture file="Interface\Buttons\ButtonHilight-Round" alphaMode="ADD"/>
      </Button>
    </Frames>

    <Scripts>
      <OnClick>
         TweetButton_OnClick(self)       
      </OnClick>
      <OnEnter>
        if self.tweet.type == "OutgoingTweet" then
        getglobal(self:GetName() .. "DeleteButton"):Show()
        end

        if self.tweet.type == "IncomingTweet" or self.tweet.type == "Reply" then
        getglobal(self:GetName() .. "RetweetButton"):Show()
        end
      </OnEnter>
      <OnLeave>
        getglobal(self:GetName() .. "DeleteButton"):Hide()
        getglobal(self:GetName() .. "RetweetButton"):Hide()
      </OnLeave>
    </Scripts>
  </Button>

  <Frame name="TweetCraftFrame" toplevel="true" enableMouse="true" movable="true" parent="UIParent" hidden="true">
    <Size>
      <AbsDimension x="384" y="512"/>
    </Size>
    <Anchors>
      <Anchor point="TOPLEFT">
        <Offset>
          <AbsDimension x="0" y="-104"/>
        </Offset>
      </Anchor>
    </Anchors>
    <HitRectInsets>
      <AbsInset left="0" right="35" top="0" bottom="75"/>
    </HitRectInsets>
    <Layers>
      <Layer level="BACKGROUND">
        <Texture file="Interface\AddOns\TweetCraft\Textures\UI-TweetCraft-TweetCraftIcon">
          <Size>
            <AbsDimension x="64" y="64"/>
          </Size>
          <Anchors>
            <Anchor point="TOPLEFT">
              <Offset>
                <AbsDimension x="6" y="-4"/>
              </Offset>
            </Anchor>
          </Anchors>
        </Texture>
      </Layer>
      <Layer level="ARTWORK">
        <Texture file="Interface\AddOns\TweetCraft\Textures\UI-TweetCraft-TopLeft">
          <Size>
            <AbsDimension x="256" y="256"/>
          </Size>
          <Anchors>
            <Anchor point="TOPLEFT"/>
          </Anchors>
        </Texture>
        <Texture file="Interface\AddOns\TweetCraft\Textures\UI-TweetCraft-TopRight">
          <Size>
            <AbsDimension x="128" y="256"/>
          </Size>
          <Anchors>
            <Anchor point="TOPRIGHT"/>
          </Anchors>
        </Texture>
        <Texture file="Interface\AddOns\TweetCraft\Textures\UI-TweetCraft-BotLeft">
          <Size>
            <AbsDimension x="256" y="256"/>
          </Size>
          <Anchors>
            <Anchor point="BOTTOMLEFT"/>
          </Anchors>
        </Texture>
        <Texture file="Interface\AddOns\TweetCraft\Textures\UI-TweetCraft-BotRight">
          <Size>
            <AbsDimension x="128" y="256"/>
          </Size>
          <Anchors>
            <Anchor point="BOTTOMRIGHT"/>
          </Anchors>
        </Texture>
        <FontString name="TweetCraftTitleText" inherits="GameFontHighlight" text="TWEETCRAFT">
          <Size>
            <AbsDimension x="300" y="14"/>
          </Size>
          <Anchors>
            <Anchor point="TOP" relativePoint="TOP">
              <Offset>
                <AbsDimension x="0" y="-15"/>
              </Offset>
            </Anchor>
          </Anchors>
        </FontString>
      </Layer>
    </Layers>
    <Frames>
      <Button name="TweetCraftFrameCloseButton" inherits="UIPanelCloseButton">
        <Anchors>
          <Anchor point="TOPRIGHT" relativePoint="TOPRIGHT">
            <Offset>
              <AbsDimension x="-30" y="-8"/>
            </Offset>
          </Anchor>
        </Anchors>
      </Button>

      <Button name="$parentTab1" inherits="TabButtonTemplate" text="INCOMING" id="1">
        <Anchors>
          <Anchor point="TOPLEFT">
            <Offset>
              <AbsDimension x="70" y="-39"/>
            </Offset>
          </Anchor>
        </Anchors>
        <Scripts>
          <OnLoad>
            PanelTemplates_TabResize(self, 0);
          </OnLoad>
          <OnClick>
            PlaySound("igCharacterInfoTab");
            PanelTemplates_Tab_OnClick(self, TweetCraftFrame)
            TweetCraftFrame_SelectedTabChanged(TweetCraftFrame)
          </OnClick>
        </Scripts>
      </Button>

      <Button name="$parentTab2" inherits="TabButtonTemplate" text="MENTIONS" id="2">
        <Anchors>
          <Anchor point="LEFT" relativeTo="$parentTab1" relativePoint="RIGHT">
            <Offset>
              <AbsDimension x="0" y="0"/>
            </Offset>
          </Anchor>
        </Anchors>
        <Scripts>
          <OnLoad>
            PanelTemplates_TabResize(self, 0);
          </OnLoad>
          <OnClick>
            PlaySound("igCharacterInfoTab");
            PanelTemplates_Tab_OnClick(self, TweetCraftFrame)
            TweetCraftFrame_SelectedTabChanged(TweetCraftFrame)
          </OnClick>
        </Scripts>
      </Button>

      <Button name="$parentTab3" inherits="TabButtonTemplate" text="OUTGOING" id="3">
        <Anchors>
          <Anchor point="LEFT" relativeTo="$parentTab2" relativePoint="RIGHT">
            <Offset>
              <AbsDimension x="0" y="0"/>
            </Offset>
          </Anchor>
        </Anchors>
        <Scripts>
          <OnLoad>
            PanelTemplates_TabResize(self, 0);
          </OnLoad>
          <OnClick>
            PlaySound("igCharacterInfoTab");
            PanelTemplates_Tab_OnClick(self, TweetCraftFrame)
            TweetCraftFrame_SelectedTabChanged(TweetCraftFrame)
          </OnClick>
        </Scripts>
      </Button>
      <Button name="TweetCraftTweetButton1" inherits="TweetCraftTweetButtonTemplate">
        <Anchors>
          <Anchor point="TOPLEFT">
            <Offset x="25" y="-80" />
          </Anchor>
        </Anchors>
      </Button>
      <Button name="TweetCraftTweetButton2" inherits="TweetCraftTweetButtonTemplate">
        <Anchors>
          <Anchor point="TOP" relativeTo="TweetCraftTweetButton1" relativePoint="BOTTOM" />
        </Anchors>
      </Button>
      <Button name="TweetCraftTweetButton3" inherits="TweetCraftTweetButtonTemplate">
        <Anchors>
          <Anchor point="TOP" relativeTo="TweetCraftTweetButton2" relativePoint="BOTTOM" />
        </Anchors>
      </Button>
      <Button name="TweetCraftTweetButton4" inherits="TweetCraftTweetButtonTemplate">
        <Anchors>
          <Anchor point="TOP" relativeTo="TweetCraftTweetButton3" relativePoint="BOTTOM" />
        </Anchors>
      </Button>
      <Button name="TweetCraftTweetButton5" inherits="TweetCraftTweetButtonTemplate">
        <Anchors>
          <Anchor point="TOP" relativeTo="TweetCraftTweetButton4" relativePoint="BOTTOM" />
        </Anchors>
      </Button>

      <ScrollFrame name="TweetsScrollFrame" inherits="FauxScrollFrameTemplate">
        <Size>
          <AbsDimension x="294" y="271" />
        </Size>
        <Anchors>
          <Anchor point="TOPLEFT">
            <Offset x="25" y="-75" />
          </Anchor>
        </Anchors>
        <Scripts>
          <OnVerticalScroll>FauxScrollFrame_OnVerticalScroll(self, offset, 52, TweetCraftFrame_UpdateTweets);</OnVerticalScroll>
        </Scripts>
      </ScrollFrame>

      <ScrollFrame name="TweetScrollFrame" inherits="UIPanelScrollFrameTemplate">
        <Size>
          <AbsDimension x="294" y="84"/>
        </Size>
        <Anchors>
          <Anchor point="TOPLEFT">
            <Offset x="25" y="-352" />
          </Anchor>
        </Anchors>
        <Scripts>
          <OnMouseDown>
            TweetEditBox:SetFocus();
          </OnMouseDown>
          <OnMouseUp>
            TweetEditBox:SetFocus();
          </OnMouseUp>
        </Scripts>
        <ScrollChild>
          <EditBox name="TweetEditBox" letters="140" multiLine="true" autoFocus="false">
            <Size>
              <AbsDimension x="291" y="78"/>
            </Size>
            <Scripts>
              <OnEscapePressed>
                self:ClearFocus();
              </OnEscapePressed>
              <OnTextChanged>
                ScrollingEdit_OnTextChanged(self, self:GetParent());
                TweetCraftFrame_UpdateButtons();
              </OnTextChanged>
              <OnCursorChanged>
                ScrollingEdit_OnCursorChanged(self, x, y, w, h);
              </OnCursorChanged>
              <OnUpdate>
                ScrollingEdit_OnUpdate(self, 0, self:GetParent());
              </OnUpdate>
            </Scripts>
            <FontString inherits="GameFontHighlight"/>
            <TextInsets left="2" top="5" right="2" bottom="5" />
          </EditBox>
        </ScrollChild>
      </ScrollFrame>

      <Button name="TweetCraftRefreshButton" inherits="UIPanelButtonTemplate" text="TWEETCRAFTREFRESH">
        <Size>
          <AbsDimension x="78" y="21"/>
        </Size>
        <Anchors>
          <Anchor point="BOTTOMLEFT" relativePoint="BOTTOMLEFT">
            <Offset>
              <AbsDimension x="17" y="54"/>
            </Offset>
          </Anchor>
        </Anchors>
        <Scripts>
          <OnClick>
            TweetCraftFrame_Refresh(self)
          </OnClick>
          <OnEnter>
            TweetCraft.AddNewbieTip(self, self:GetText(), 1, 1, 1, TWEETCRAFTSENDREFRESHDESC, 1)
          </OnEnter>
          <OnLeave>
            GameTooltip:Hide()
          </OnLeave>
        </Scripts>
      </Button>

      <Button name="TweetCraftQueueButton" inherits="UIPanelButtonTemplate" text="QUEUE">
        <Size>
          <AbsDimension x="83" y="21"/>
        </Size>
        <Anchors>
          <Anchor point="LEFT" relativePoint="RIGHT" relativeTo="TweetCraftRefreshButton">
            <Offset>
              <AbsDimension x="2" y="0"/>
            </Offset>
          </Anchor>
        </Anchors>
        <Scripts>
          <OnClick>
            TweetCraftFrame_Queue(self)
          </OnClick>
          <OnEnter>
            TweetCraft.AddNewbieTip(self, QUEUE, 1, 1, 1, QUEUEDESC, 1)
          </OnEnter>
          <OnLeave>
            GameTooltip:Hide()
          </OnLeave>
        </Scripts>
      </Button>

      <Button name="TweetCraftScreenshotButton" inherits="UIPanelButtonTemplate" text="SCREENSHOT">
        <Size>
          <AbsDimension x="84" y="21"/>
        </Size>
        <Anchors>
          <Anchor point="LEFT" relativePoint="RIGHT" relativeTo="TweetCraftQueueButton">
            <Offset>
              <AbsDimension x="2" y="0"/>
            </Offset>
          </Anchor>
        </Anchors>
        <Scripts>
          <OnClick>
            TweetCraftFrame_Screenshot(self)
          </OnClick>
          <OnEnter>
            TweetCraft.AddNewbieTip(self, SCREENSHOT, 1, 1, 1, SCREENSHOTDESC, 1)
          </OnEnter>
          <OnLeave>
            GameTooltip:Hide()
          </OnLeave>
        </Scripts>
      </Button>

      <Button name="TweetCraftOptionsButton" inherits="UIPanelButtonTemplate" text="OPTIONS">
        <Size>
          <AbsDimension x="79" y="21"/>
        </Size>
        <Anchors>
          <Anchor point="LEFT" relativePoint="RIGHT" relativeTo="TweetCraftScreenshotButton">
            <Offset>
              <AbsDimension x="2" y="0"/>
            </Offset>
          </Anchor>
        </Anchors>
        <Scripts>
          <OnClick>
            TweetCraftFrame_Options(self)
          </OnClick>
          <OnEnter>
            TweetCraft.AddNewbieTip(self, OPTIONS, 1, 1, 1, OPTIONSDESC, 1)
          </OnEnter>
          <OnLeave>
            GameTooltip:Hide()
          </OnLeave>
        </Scripts>
      </Button>
    </Frames>
    <Scripts>
      <OnLoad>
      </OnLoad>
      <OnLoad>
        tinsert(UISpecialFrames,this:GetName());
        TweetCraftFrame_OnLoad(self)

        -- Set the number of tabs, select the first tab (Incoming) and update the tabs
        PanelTemplates_SetNumTabs(self, 3)
        self.selectedTab = 1;
        PanelTemplates_UpdateTabs(self);
        TweetCraftFrame_SelectedTabChanged(self)
      </OnLoad>
      <OnEvent>
        TweetCraftFrame_OnEvent(self, event, ...)
      </OnEvent>
      <OnShow>
        PlaySound("igCharacterInfoOpen");
        TweetCraftFrame_UpdateButtons()
      </OnShow>
      <OnHide>
        PlaySound("igCharacterInfoClose");
      </OnHide>
    </Scripts>
  </Frame>
</Ui>